package br.com.unirio.autocar.visao;

import java.util.ArrayList;
import java.util.List;

import br.com.unirio.autocar.dados.RepositorioDeAcessorio;
import br.com.unirio.autocar.modelo.Acessorio;
import br.com.unirio.autocar.visao.models.ModeloTabelaAcessorio;

public class EstoqueAcessorio extends javax.swing.JFrame
{

    /**
     * 
     */
    private static final long serialVersionUID = 2324785664023063977L;
    /**
     * Creates new form Estoque
     */

    RepositorioDeAcessorio repositorioDeAcessorios;

    public EstoqueAcessorio()
    {
	initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents()
    {
	repositorioDeAcessorios = new RepositorioDeAcessorio();

	List<Acessorio> listaAcessorios = new ArrayList<Acessorio>();

	listaAcessorios = repositorioDeAcessorios.obterTodos();

	labelAcessorios = new javax.swing.JLabel();
	jScrollPane1 = new javax.swing.JScrollPane();
	tabelaAcessorios = new javax.swing.JTable();

	setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

	labelAcessorios.setFont(new java.awt.Font("Microsoft Sans Serif", 0, 18)); // NOI18N
	labelAcessorios.setText("Acessorios em Estoque");
	tabelaAcessorios.setSize(600, 480);

	tabelaAcessorios.setModel(new ModeloTabelaAcessorio(listaAcessorios));
	jScrollPane1.setViewportView(tabelaAcessorios);

	javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
	getContentPane().setLayout(layout);
	layout.setHorizontalGroup(layout
		.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
		.addGroup(
			layout.createSequentialGroup().addContainerGap(300, Short.MAX_VALUE)
				.addComponent(labelAcessorios).addContainerGap(300, Short.MAX_VALUE))
		.addGroup(
			layout.createSequentialGroup()
				.addGap(57, 57, 57)
				.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1060,
					javax.swing.GroupLayout.PREFERRED_SIZE)
				.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
	layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
		layout.createSequentialGroup()
			.addContainerGap()
			.addComponent(labelAcessorios)
			.addGap(26, 26, 26)
			.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 620,
				javax.swing.GroupLayout.PREFERRED_SIZE)
			.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

	pack();
    }// </editor-fold>

    /**
     * @param args
     *            the command line arguments
     */
    public static void main(String args[])
    {
	/* Set the Nimbus look and feel */
	// <editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
	/*
	 * If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
	 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
	 */
	try
	{
	    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
	    {
		if ("Nimbus".equals(info.getName()))
		{
		    javax.swing.UIManager.setLookAndFeel(info.getClassName());
		    break;
		}
	    }
	}
	catch (ClassNotFoundException ex)
	{
	    java.util.logging.Logger.getLogger(EstoqueAcessorio.class.getName()).log(java.util.logging.Level.SEVERE,
		    null, ex);
	}
	catch (InstantiationException ex)
	{
	    java.util.logging.Logger.getLogger(EstoqueAcessorio.class.getName()).log(java.util.logging.Level.SEVERE,
		    null, ex);
	}
	catch (IllegalAccessException ex)
	{
	    java.util.logging.Logger.getLogger(EstoqueAcessorio.class.getName()).log(java.util.logging.Level.SEVERE,
		    null, ex);
	}
	catch (javax.swing.UnsupportedLookAndFeelException ex)
	{
	    java.util.logging.Logger.getLogger(EstoqueAcessorio.class.getName()).log(java.util.logging.Level.SEVERE,
		    null, ex);
	}
	// </editor-fold>

	/* Create and display the form */
	java.awt.EventQueue.invokeLater(new Runnable() {
	    public void run()
	    {
		new EstoqueAcessorio().setVisible(true);
	    }
	});
    }

    // Variables declaration - do not modify
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel labelAcessorios;
    private javax.swing.JTable tabelaAcessorios;
    // End of variables declaration
}
